<div class="tmd-doc">
<h1 class="tmd-header-1">
An Introduction of Go
</h1>
<p></p>
<div class="tmd-usual">
Go is a compiled and static typed programming language born from Google. Many of the core Go design and tool development team members have many years of experience in the field of programming language research.
</div>
<p></p>
<div class="tmd-usual">
Go has many features. Some are unique, some are borrowed from other programming languages:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
built-in concurrent programming support
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
goroutines (green threads) and start new goroutines easily.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
channels (based on CSP model) and select mechanisms to do synchronizations between goroutines.
</div>
</li>
</ul>
<p></p>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
the container <code class="tmd-code-span">map</code> and <code class="tmd-code-span">slice</code> types are first-class citizens.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
polymorphism through interfaces.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
value boxing and reflection through interfaces.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
pointers.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
function closures.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
methods.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
deferred function calls.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
type embedding.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
type deduction.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
memory safety.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
automatic garbage collection.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
great cross-platform compatibility.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
custom generics (since Go 1.18).
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
custom iterators (since Go 1.23).
</div>
</li>
</ul>
<p></p>
<div class="tmd-usual">
Besides the above features, further highlights are:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
The syntax of Go is deliberately designed to be simple, clean, and similar to other popular programming languages. This makes Go programming easy to pick up.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
Go comes with a great set of standard code packages which provide all kinds of common functionalities. Most of the packages are cross-platform.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
Go also has an active community, and there are plenty of high quality third party Go libraries and projects to import and use.
</div>
</li>
</ul>
<p></p>
<div class="tmd-usual">
Go programmers are often called gophers.
</div>
<p></p>
<div class="tmd-usual">
In fact, although Go is a compiled and static typed programming language, Go also has many features which are usually only available in dynamic script languages. It is hard to combine these two kinds into one language, but Go did it. In other words, Go owns both the strictness of static languages and the flexibility of dynamic languages. I can't say there are not any compromises between the two, but the effect of the compromises is much weaker than the benefits of the combination in Go.
</div>
<p></p>
<div class="tmd-usual">
Readability is an important factor which affects the design of Go heavily. It is not hard for a gopher to understand the Go code written by other gophers.
</div>
<p></p>
<div class="tmd-usual">
Currently, the most popular Go compiler is written in Go and maintained by the Go design team. Later we shall call it the standard Go compiler, or <code class="tmd-code-span">gc</code> (an abbreviation for Go compiler, not for garbage collection GC). The Go design team also maintains a second Go compiler, <code class="tmd-code-span">gccgo</code>. Nowadays it's use is less popular than <code class="tmd-code-span">gc</code>, but it always serves as a reference, and both compilers are in active development. As of now the Go team focuses on the improvement of <code class="tmd-code-span">gc</code>.
</div>
<p></p>
<div class="tmd-usual">
<code class="tmd-code-span">gc</code> is provided in Go Toolchain (a set of tools for Go development maintained by Go team). Go Toolchain 1.0 was released in March, 2012. The version of Go is consistent with the version of Go Toolchain. There were/are two major versions released each year.
</div>
<p></p>
<div class="tmd-usual">
Since the release of Go 1.0, the syntax of Go has changed a little, but there were/are many improvements for the tools in Go Toolchain, from version to version, especially for <code class="tmd-code-span">gc</code>. For example, noticeable lags caused by garbage collecting is a common criticism for languages with automatic memory management. But since Go 1.8, improvements made for the concurrent garbage collection implementation in <code class="tmd-code-span">gc</code> basically eliminated the lag problem.
</div>
<p></p>
<div class="tmd-usual">
<code class="tmd-code-span">gc</code> supports cross-platform compilation. For example, we can build a Windows executable on a Linux OS, and vice versa.
</div>
<p></p>
<div class="tmd-usual">
Programs written in go language mostly compile very fast. Compilation time is an important factor for the happiness in development. Short build time is one reason why many programmers like programming with Go.
</div>
<p></p>
<div class="tmd-usual">
Advantages of Go executables are:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
small memory footprint
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
fast code execution (much faster than dynamic script languages, but a little slower than C/C++)
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
short warm-up duration (so great deployment experience)
</div>
</li>
</ul>
<p></p>
<div class="tmd-usual">
Some other compiled languages, such as C/C++/Rust may also have these three advantages (and they may have their respective advantages compared to Go), but they lack three important characteristics of Go:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
fast compilation results in happy local development experience and short deployment iteration cycles
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
flexible, like dynamic languages
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
built-in concurrent programming support
</div>
</li>
</ul>
<p></p>
<div class="tmd-usual">
All the above advantages combined make Go an outstanding language and a good choice for many kinds of projects, especially for network apps and system tools.
</div>
<p></p>
<div class="tmd-usual">
Finally, Go is not perfect in all aspects. There are certain trade-offs in Go design. And Go really has some shortcomings. For example,
</div>
<p></p>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
Go doesn't support arbitrary immutable values now, which leads to that many values which are not intended to be modified in standard packages are declared as variables. This is a potential security weak point for some Go programs.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
Increased complexity and bugs in recent Releases: Recent changes introduced in Go 1.22 and 1.23 have added unexpected complexities and implicit behaviors to the language's semantics. Furthermore, these changes have brought about backward-incompatibility issues and bugs, which the change makers appear reluctant to resolve.
</div>
</li>
</ul>
<p></p>
</div>
